package com.hex.liyue.commonmodule.manager;

import android.text.TextUtils;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hex.liyue.commonmodule.bean.BaseBean;
import com.hex.liyue.commonmodule.config.ConstantUrl;
import com.hex.liyue.commonmodule.net.OkHttpUtil;
import com.hex.liyue.commonmodule.net.RequestPacket;
import com.hex.liyue.commonmodule.net.ResponseListener;
import com.hex.liyue.commonmodule.utils.EncryptionUtil;
import com.hex.liyue.commonmodule.utils.L;
import com.hex.liyue.giftmodule.bean.DiscountDetailsBean;
import com.hex.liyue.giftmodule.bean.DiscountGiftsBean;
import com.hex.liyue.giftmodule.bean.GiveGiftsBean;
import com.hex.liyue.giftmodule.bean.HarverDetailsBean;
import com.hex.liyue.giftmodule.bean.HarvesGiftsBean;
import com.hex.liyue.giftmodule.bean.MyGiftsResultBean;
import com.hex.liyue.launchdatemodule.bean.LaunchDateBean;
import com.hex.liyue.launchdatemodule.bean.LaunchListResultBean;
import com.hex.liyue.lookingdatemodule.bean.AppointmentDetailsResultBean;
import com.hex.liyue.lookingdatemodule.bean.HotNewResultBean;
import com.hex.liyue.lookingdatemodule.bean.LookingListResultBean;
import com.hex.liyue.messagemodule.bean.SystemMsgResultBean;
import com.hex.liyue.nearmodule.bean.NearListBean;
import com.hex.liyue.storemodule.bean.FragmentStoreBean;
import com.hex.liyue.storemodule.bean.PayOrderDetailsResultBean;
import com.hex.liyue.usermodule.bean.AddressResultBean;
import com.hex.liyue.usermodule.bean.LoginResultBean;
import com.hex.liyue.usermodule.bean.MachPhoneResultBean;
import com.hex.liyue.usermodule.bean.MoreRecordsResultBean;
import com.hex.liyue.usermodule.bean.MyBankInfoResultBean;
import com.hex.liyue.usermodule.bean.MyDownLinesResultBean;
import com.hex.liyue.usermodule.bean.MyFriendsResultBean;
import com.hex.liyue.usermodule.bean.MyMessageResultBean;
import com.hex.liyue.usermodule.bean.MyOrderResultBean;
import com.hex.liyue.usermodule.bean.MyPhotoBean;
import com.hex.liyue.usermodule.bean.MyUpLinesResultBean;
import com.hex.liyue.usermodule.bean.MyWalletResultbean;
import com.hex.liyue.usermodule.bean.OrderDetailsResultBean;
import com.hex.liyue.usermodule.bean.RegistResultBean;
import com.hex.liyue.usermodule.bean.UpdateMyPhotoBean;
import com.hex.liyue.usermodule.bean.VideoListsBean;

import java.util.List;


/**
 * Created by wj on 2016/6/12.
 * 这是一个所有网络请求的管理工具类
 */
public class HttpManager {
    private static HttpManager httpManager;

    private HttpManager() {
    }

    public static HttpManager getInstance() {
        if (httpManager == null) {
            synchronized (HttpManager.class) {
                httpManager = new HttpManager();
            }
        }
        return httpManager;
    }

    /**
     * 这是一个登录的方法
     *
     * @param phone            手机号
     * @param pwd              密码
     * @param responseListener 回调监听
     */
    public void login(String phone, String pwd, ResponseListener<LoginResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("mobile", phone);
        jsonObject.put("password", pwd);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_login");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);

    }

    /**
     * 这是一个注册的方法
     *
     * @param phone            手机号
     * @param name             姓名
     * @param pwd              密码
     * @param vcode            验证码
     * @param inviteVcode      邀请码
     * @param responseListener 回调监听
     */
    public void regist(String phone, String name, String pwd, String avatar, String vcode, String inviteVcode, ResponseListener<RegistResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("mobile", phone);
        jsonObject.put("nickname", name);
        jsonObject.put("password", pwd);
        if (!TextUtils.isEmpty(avatar)) {
            jsonObject.put("avatar", avatar);
        }
        jsonObject.put("sms_code", vcode);
        jsonObject.put("invite_code", inviteVcode);


        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_register");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 这是一个无密码登录的方法
     *
     * @param phone            手机号
     * @param vcode            验证码
     * @param responseListener 回调监听
     */
    public void vcodeLogin(String phone, String vcode, ResponseListener responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("mobile", phone);
        jsonObject.put("sms_code", vcode);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_login");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 这是一个修改密码的方法
     *
     * @param phone            手机号
     * @param vcode            验证码
     * @param password         新密码
     * @param responseListener 回调监听
     */
    public void resetPwd(String phone, String vcode, String password, ResponseListener<BaseBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("mobile", phone);
        jsonObject.put("sms_code", vcode);
        jsonObject.put("new_password", password);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_forgetPassword");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 这是一个获取手机号验证码的方法
     *
     * @param phone            手机号
     * @param sms_type         验证码类型1,注册,2登录,3忘记密码/修改密码,4,邀请人
     * @param responseListener 回调监听
     */
    public void getvcode(String phone, int sms_type, ResponseListener<BaseBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("sms_mobile", phone);
        jsonObject.put("sms_type", sms_type);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "sms_send");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 这是发起约会的方法
     *
     * @param uid
     * @param event            想说的话
     * @param location         约会地址
     * @param invitations_time 约会时间
     * @param video            约会视频url
     * @param remark           留言信息
     * @param responseListener
     */
    public void createAppointment(
            String uid,
            String event,
            String location,
            String invitations_time,
            String video,
            String remark,
            String gift_id,
            String gps_x,
            String gps_y,
            ResponseListener<LaunchDateBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("event", event);
        jsonObject.put("location", location);
        jsonObject.put("invitations_time", invitations_time);
        jsonObject.put("video", video);
        jsonObject.put("remark", remark);
        jsonObject.put("gps_x", gps_x);
        jsonObject.put("gps_y", gps_y);
        jsonObject.put("wanted_gift_id", gift_id);


        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "yue_launch");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }


    /**
     * 这是一个搜索约会的方法
     *
     * @param uid
     * @param sex              性别
     * @param type             hot:热门 new:最新
     * @param page
     * @param pagenum
     * @param responseListener
     */
    public void searchAppointment(
            String uid,
            int sex,
            String type,
            int page,
            int pagenum,
            ResponseListener<HotNewResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("sex", sex);
        jsonObject.put("type", type);
        jsonObject.put("page", page);
        jsonObject.put("pagenum", pagenum);


        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "yue_appointmentList");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 查找约会详情
     *
     * @param uid
     * @param appointment_id   约会id
     * @param responseListener
     */
    public void findAppointmentDetails(
            String uid,
            String appointment_id,
            ResponseListener<AppointmentDetailsResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("appointment_id", appointment_id);


        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "yue_detail");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 这是一个修改密码的方法
     *
     * @param oldPwd           旧密码
     * @param newPwd           新密码
     * @param responseListener 回调监听
     */
    public void updataPwd(String uid, String oldPwd, String newPwd, ResponseListener<BaseBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("new_password", newPwd);
        jsonObject.put("old_password", oldPwd);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_changePassword");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 这是一个意见反馈的方法
     *
     * @param uid
     * @param mobile           手机号
     * @param content          内容
     * @param responseListener
     */
    public void feedBack(String uid, String mobile, String content, ResponseListener<BaseBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("mobile", mobile);
        jsonObject.put("content", content);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_feedback");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 这是上线下线小伙伴列表的方法
     *
     * @param uid
     * @param page
     * @param page_num
     * @param responseListener
     */
    public void myFrendis(String uid, int page, int page_num, ResponseListener<MyFriendsResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("page", page);
        jsonObject.put("page_num", page_num);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_getMates");
        requestPacket.addArgument("query", "user_getInvitorProfile");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 获取下线小伙伴信息
     *
     * @param uid
     * @param page
     * @param page_num
     * @param responseListener
     */
    public void myMoreFrendis(String uid, int page, int page_num, ResponseListener<MyDownLinesResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("page", page);
        jsonObject.put("page_num", page_num);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_getMates");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 这是下填写上线邀请码的方法
     *
     * @param uid
     * @param invite_code      上线邀请码
     * @param responseListener
     */
    public void offLinesMyFrendis(String uid, String invite_code, ResponseListener<MyUpLinesResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("invite_code", invite_code);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_getInvitorProfile");
        requestPacket.addArgument("query", "user_updateInviteCode");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 这是一个新增收货地址的方法
     *
     * @param uid
     * @param username         收货人
     * @param mobile           联系方式
     * @param addressDetail    详细地址
     * @param provinceId       省市id
     * @param provinceName     省市名称
     * @param cityId           城市id
     * @param cityName         城市名称
     * @param districtId       街道id
     * @param districtName     街道名称
     * @param responseListener
     */
    public void addAddress(
            String uid,
            String username,
            String mobile,
            String addressDetail,
            String provinceId,
            String provinceName,
            String cityId,
            String cityName,
            String districtId,
            String districtName,
            ResponseListener<BaseBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("username", username);
        jsonObject.put("mobile", mobile);
        jsonObject.put("address_detail", addressDetail);
        jsonObject.put("province_id", provinceId);
        jsonObject.put("province_name", provinceName);
        jsonObject.put("city_id", cityId);
        jsonObject.put("city_name", cityName);
        jsonObject.put("district_id", districtId);
        jsonObject.put("district_name", districtName);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_updateAddress");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 获取我的收货地址
     *
     * @param uid
     * @param responseListener
     */
    public void getAddressList(String uid, ResponseListener<AddressResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_getAddressList");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 这是一个编辑收货地址的方法
     *
     * @param delivery_id      地址id
     * @param uid
     * @param username         收货人
     * @param mobile           联系方式
     * @param addressDetail    详细地址
     * @param provinceId       省市id
     * @param provinceName     省市名称
     * @param cityId           城市id
     * @param cityName         城市名称
     * @param districtId       街道id
     * @param districtName     街道名称
     * @param responseListener
     */
    public void upadteAddress(
            String delivery_id,
            String uid,
            String username,
            String mobile,
            String addressDetail,
            String provinceId,
            String provinceName,
            String cityId,
            String cityName,
            String districtId,
            String districtName,
            ResponseListener<BaseBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("delivery_id", delivery_id);
        jsonObject.put("uid", uid);
        jsonObject.put("username", username);
        jsonObject.put("mobile", mobile);
        jsonObject.put("address_detail", addressDetail);
        jsonObject.put("province_id", provinceId);
        jsonObject.put("province_name", provinceName);
        jsonObject.put("city_id", cityId);
        jsonObject.put("city_name", cityName);
        jsonObject.put("district_id", districtId);
        jsonObject.put("district_name", districtName);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_updateAddress");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 这是获取商城列表的方法
     *
     * @param uid
     * @param page
     * @param pagenum
     * @param sortPrice        true:价格从高到低 false:价格从的低到高
     * @param responseListener
     */
    public void getStoreList(String uid, int page, int pagenum, boolean sortPrice, ResponseListener<FragmentStoreBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("page", page);
        jsonObject.put("pagenum", pagenum);
        if (sortPrice) {
            //高-低
            jsonObject.put("order", "price desc");
        } else {
            jsonObject.put("order", "price asc");
        }
        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "gift_giftList");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 删除收货地址
     *
     * @param uid
     * @param delivery_id      收货地址id
     * @param responseListener
     */
    public void deleteAddress(String uid, String delivery_id, ResponseListener<BaseBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("delivery_id", delivery_id);
        jsonObject.put("status", "-1");

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_updateAddress");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 把地址改成默认
     *
     * @param uid
     * @param delivery_id      地址id
     * @param responseListener
     */
    public void updateAddressFirst(String uid, String delivery_id, ResponseListener<BaseBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("delivery_id", delivery_id);
        jsonObject.put("is_default", "1");

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_updateAddress");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }


    /**
     * 这是获取我的照片的方法
     *
     * @param uid
     * @param responseListener
     */
    public void getAddPhoto(String uid, ResponseListener<MyPhotoBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_getUserImage");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 这是一个匹配通讯录的方法
     *
     * @param uid
     * @param list             联系人信息列表
     * @param responseListener
     */
    public void machingPhone(String uid, JSONObject list, ResponseListener<MachPhoneResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("contacts", list);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_matchContacts");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 这是一个更新个人信息的方法
     *
     * @param uid
     * @param avatar           头像url
     * @param nickname         用户名
     * @param birthday         日期
     * @param signature        签名
     * @param star_sign        星座
     * @param sex              性别 1男 2女
     * @param responseListener
     */
    public void updateMyMessage(String uid, String avatar, String nickname, long birthday, String signature, String star_sign, int sex, ResponseListener<MyMessageResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        if (!TextUtils.isEmpty(avatar)) {
            jsonObject.put("avatar", avatar);
        }
        jsonObject.put("nickname", nickname);
        jsonObject.put("birthday", birthday);
        jsonObject.put("signature", signature);
        jsonObject.put("star_sign", star_sign);
        jsonObject.put("sex", sex);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_updateProfile");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 这是一个获取个人信息的方法
     *
     * @param uid
     * @param responseListener
     */
    public void getMyMessage(String uid, ResponseListener<MyMessageResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_getProfile");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 这是上传照片的方法
     *
     * @param uid
     * @param pics             图片url数组
     * @param responseListener
     */
    public void getUpdatePhoto(String uid, String[] pics, ResponseListener<UpdateMyPhotoBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("pics", pics);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_addUserImage");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 获取我的礼物方法
     *
     * @param uid
     * @param responseListener
     */
    public void myGiftList(String uid, ResponseListener<MyGiftsResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "gift_myGiftList");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 发送礼物
     *
     * @param from_uid         发送者id
     * @param to_uid           接收人id
     * @param appointment_id   约会id
     * @param gift_list        礼物集合
     * @param responseListener
     */
    public void sendGift(String from_uid, String to_uid, String appointment_id, JSONArray gift_list, ResponseListener<BaseBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("from_uid", from_uid);
        jsonObject.put("to_uid", to_uid);
        jsonObject.put("appointment_id", appointment_id);
        jsonObject.put("gift_list", gift_list);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "gift_sendGift");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 获取折现礼物列表方法
     *
     * @param uid
     * @param responseListener
     */
    public void getDiscountGifts(String uid, int page, int pagenum, ResponseListener<DiscountGiftsBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("page", page);
        jsonObject.put("pagenum", pagenum);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "gift_cashList");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 我发起的约会列表
     *
     * @param uid
     * @param page
     * @param pagenum
     * @param responseListener
     */
    public void launchList(String uid, int page, int pagenum, ResponseListener<LaunchListResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("page", page);
        jsonObject.put("pagenum", pagenum);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "yue_launchList");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 获取收货的礼物列表方法
     *
     * @param uid
     * @param responseListener
     */
    public void getHarvesGifts(String uid, int page, int pagenum, ResponseListener<HarvesGiftsBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("page", page);
        jsonObject.put("pagenum", pagenum);
        jsonObject.put("type", null);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "gift_exportList");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 我应约的约会
     *
     * @param uid
     * @param page
     * @param pagenum
     * @param responseListener
     */
    public void applyList(String uid, int page, int pagenum, ResponseListener<LookingListResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("page", page);
        jsonObject.put("pagenum", pagenum);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "yue_applyList");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 获取赠送的礼物列表方法
     *
     * @param uid
     * @param responseListener
     */
    public void getGiveGifts(String uid, int page, int pagenum, ResponseListener<GiveGiftsBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("type", null);
        jsonObject.put("page", page);
        jsonObject.put("pagenum", pagenum);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "gift_sendList");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 接受应约
     *
     * @param uid
     * @param apply_uid        应约人id
     * @param accept_id        应约表id
     * @param responseListener
     */
    public void accept(String uid, String apply_uid, String accept_id, ResponseListener<BaseBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("apply_uid", apply_uid);
        jsonObject.put("accept_id", accept_id);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "yue_accept");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 拒绝应约人约会
     *
     * @param uid              用户ID
     * @param accept_id        约会申请ID
     * @param appointment_id   约会ID
     * @param responseListener
     */
    public void reject(String uid, String accept_id, String appointment_id, ResponseListener<BaseBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("accept_id", accept_id);
        jsonObject.put("appointment_id", appointment_id);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "yue_reject");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 取消约会
     *
     * @param uid
     * @param appointment_id   约会id
     * @param responseListener
     */
    public void cancelAppointment(String uid, String appointment_id, ResponseListener<BaseBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("appointment_id", appointment_id);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "yue_cancel");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 完成约会
     *
     * @param uid
     * @param appointment_id 约会id
     * @param to_uid         发起人id
     */
    public void successAppointment(String uid, String appointment_id, String to_uid, ResponseListener<BaseBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("appointment_id", appointment_id);
        jsonObject.put("to_uid", to_uid);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "yue_success");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 获取我的钱包信息
     *
     * @param uid
     * @param page
     * @param page_num
     * @param responseListener
     */
    public void user_getWallet(String uid, int page, int page_num, ResponseListener<MyWalletResultbean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("page", page);
        jsonObject.put("page_num", page_num);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_getWallet");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }


    /**
     * 获取更多交易记录
     *
     * @param uid
     * @param page
     * @param page_num
     * @param responseListener
     */
    public void user_getTransactionRecords(String uid, int page, int page_num, ResponseListener<MoreRecordsResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("page", page);
        jsonObject.put("page_num", page_num);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_getTransactionRecords");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 这是一个获取系统消息的方法
     *
     * @param responseListener 回调监听
     */
    public void getSystemMsg(int page, int page_num, ResponseListener<SystemMsgResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", UserManager.getUserId());//测试使用101173
        jsonObject.put("page", page);
        jsonObject.put("page_num", page_num);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "msg_msgList");
        requestPacket.addArgument("data", jsonObject.toJSONString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 添加/修改 银行卡信息
     *
     * @param bank_id          银行卡id
     * @param uid
     * @param username         真是姓名
     * @param bank_number      银行卡号
     * @param id_front_photo   身份证正面照
     * @param id_back_photo    身份证反面照
     * @param bank_front_photo 银行卡正面照
     * @param bank_back_photo  银行卡反面照
     * @param bank_name        银行卡名称
     * @param responseListener
     */
    public void user_updateBankCard(
            String bank_id,
            String uid,
            String username,
            String bank_number,
            String id_front_photo,
            String id_back_photo,
            String bank_front_photo,
            String bank_back_photo,
            String bank_name,
            ResponseListener<BaseBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        if (!TextUtils.isEmpty(bank_id)) {
            jsonObject.put("bank_id", bank_id);
        }
        jsonObject.put("uid", uid);
        jsonObject.put("username", username);
        jsonObject.put("bank_number", bank_number);
        jsonObject.put("id_front_photo", id_front_photo);
        jsonObject.put("id_back_photo", id_back_photo);
        jsonObject.put("bank_front_photo", bank_front_photo);
        jsonObject.put("bank_back_photo", bank_back_photo);
        jsonObject.put("bank_name", bank_name);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_updateBankCard");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 获取银行卡信息
     *
     * @param uid
     * @param responseListener
     */
    public void user_getBankCard(String uid, ResponseListener<MyBankInfoResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_getBankCard");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }


    /**
     * 提现方法
     *
     * @param uid
     * @param transaction_price 提现金额
     * @param responseListener
     */
    public void user_withdrawCash(String uid, long transaction_price, ResponseListener<BaseBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("transaction_price", transaction_price);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_withdrawCash");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 折现礼物
     *
     * @param uid
     * @param gift_list        礼物列表
     * @param responseListener
     */
    public void gift_discount(String uid, JSONArray gift_list, ResponseListener<DiscountDetailsBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("gift_list", gift_list);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "gift_discount");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 礼物收货
     *
     * @param uid
     * @param gift_list        礼物列表
     * @param delivery_id      收货地址id
     * @param responseListener
     */
    public void gift_export(String uid, JSONArray gift_list, String delivery_id, ResponseListener<HarverDetailsBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("gift_list", gift_list);
        jsonObject.put("delivery_id", delivery_id);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "gift_export");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 生成订单
     *
     * @param uid
     * @param gift_id          礼物id
     * @param gift_num         礼物数量
     * @param responseListener
     */
    public void orders_create(String uid, String gift_id, int gift_num, ResponseListener<PayOrderDetailsResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("gift_id", gift_id);
        jsonObject.put("gift_num", gift_num);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "orders_create");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 支付
     *
     * @param uid
     * @param order_id         订单id
     * @param password         验证密码
     * @param type             1余额支付 2微信支付 3支付宝支付
     * @param responseListener
     */
    public void orders_pay(String uid, String order_id, String password, int type, ResponseListener<PayOrderDetailsResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("order_id", order_id);
        jsonObject.put("type", type);
        jsonObject.put("password", password);
        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "orders_pay");
        L.i("支付信息", jsonObject.toString());
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 订单列表
     *
     * @param uid
     * @param page
     * @param pagenum
     * @param responseListener
     */
    public void orders_orderList(String uid, int page, int pagenum, ResponseListener<MyOrderResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("page", page);
        jsonObject.put("pagenum", pagenum);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "orders_orderList");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 获取订单详情
     *
     * @param uid
     * @param order_id         订单id
     * @param responseListener
     */
    public void orders_detail(String uid, String order_id, ResponseListener<OrderDetailsResultBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("order_id", order_id);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "orders_detail");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 取消订单
     *
     * @param uid
     * @param order_id         订单id
     * @param responseListener
     */
    public void orders_cancel(String uid, String order_id, ResponseListener<BaseBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("order_id", order_id);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "orders_cancel");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 折现详情
     *
     * @param uid
     * @param user_gift_cash_id 礼物折现id
     * @param responseListener
     */
    public void getDiscountDetailsGifts(String uid, String user_gift_cash_id, ResponseListener<DiscountDetailsBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("user_gift_cash_id", user_gift_cash_id);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "gift_cashDetail");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 收货详情
     *
     * @param uid
     * @param user_gift_export_id 礼物收货id
     * @param responseListener
     */
    public void getHarvesDetialsGifts(String uid, String user_gift_export_id, ResponseListener<HarverDetailsBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);
        jsonObject.put("user_gift_export_id", user_gift_export_id);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "gift_exportDetail");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 举报界面
     *
     * @param uid
     * @param responseListener
     */
    public void getReport(String uid, String type, String target_id, String reason, String content, ResponseListener<BaseBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("from_uid", uid);
        jsonObject.put("type", type);
        jsonObject.put("target_id", target_id);
        jsonObject.put("reason", reason);
        jsonObject.put("content", content);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_report");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 个人中心获取小视频的列表
     *
     * @param uid
     * @param responseListener
     */
    public void getVideoLists(String uid, ResponseListener<VideoListsBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", uid);

        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_getVideos");
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 这是一个获取附近模块列表的方法
     *
     * @param page             页数
     * @param pagernum         每页的数量
     * @param gpsx             定位的经度
     * @param gpsy             定位的纬度
     * @param responseListener 回调监听
     */
    public void getNearList(int page, int pagernum, String gpsx, String gpsy, ResponseListener<NearListBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", UserManager.getUserId());
        jsonObject.put("page", page);
        jsonObject.put("pagenum", pagernum);
        jsonObject.put("gps_x", gpsx);
        jsonObject.put("gps_y", gpsy);
        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "yue_nearest");
        L.d("附近列表的请求路径", jsonObject.toString());
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }

    /**
     * 这是一个删除个人照片的方法
     *
     * @param pics             照片id
     * @param responseListener 回调监听
     */
    public void deleteUserPhotos(List<Integer> pics, ResponseListener<NearListBean> responseListener) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("uid", UserManager.getUserId());
        JSONArray jsonArray=new JSONArray();
        for (Integer integer:pics){
            jsonArray.add(integer);
        }
      //  L.d("图片集合", jsonArray);
        jsonObject.put("pics", jsonArray);
        RequestPacket requestPacket = new RequestPacket();
        requestPacket.url = ConstantUrl.getBaseUrl();
        requestPacket.addArgument("query", "user_delUserImage");
        L.d("图片集合", jsonObject.toString());
        requestPacket.addArgument("data", jsonObject.toString());
        OkHttpUtil.Request(RequestPacket.POST, EncryptionUtil.encryptionDataPOST(requestPacket), responseListener);
    }
}
